<template>
  <div>
    <form action="" @submit.prevent="sendLogin">
      <label for="">账号</label>
      <input type="text" name="user" ref="userInput">
      <label for="">密码</label>
      <input type="password" name="password" id="">
      <button type="submit">提交</button>
    </form>
    <router-link to="/">首页</router-link>
  </div>
</template>

<script>
export default {
  name: 'login',
  data () {
    return {

    }
  },
  methods: {
    // 登录
    sendLogin () {
      const username = this.$refs.userInput.values
      this.$local.save('I CAN', {
        login: true,
        username: username
      })

      let redirect = this.$route.query.redirect

      if (!redirect) {
        redirect = 'project'
      }
      this.$router.push({
        path: '/' + redirect
      })
    }
  }
}
</script>

<style lang="">

</style>
